package com.quad.innovators.salesease.controller.stock;

import com.quad.innovators.salesease.annotation.Log;
import com.quad.innovators.salesease.common.result.PageResultBean;
import com.quad.innovators.salesease.common.result.Result;
import com.quad.innovators.salesease.constants.SystemConstants;
import com.quad.innovators.salesease.enums.LogModuleEnum;
import com.quad.innovators.salesease.model.query.stock.ProductInfoIdentityPageGroupQuery;
import com.quad.innovators.salesease.model.query.stock.ProductInfoIdentityPageQuery;
import com.quad.innovators.salesease.model.vo.stock.ProductInfoDetailVO;
import com.quad.innovators.salesease.model.vo.stock.ProductInfoIdentityGroupVO;
import com.quad.innovators.salesease.model.vo.stock.ProductInfoIdentityVO;
import com.quad.innovators.salesease.service.stock.ProductInfoIdentityService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author : shanshan.li
 * @createTime : 2025/3/28 15:53
 * @Version : 1.0 
 */
@Tag(name = "16.产品身份信息")
@RestController
@RequestMapping(SystemConstants.BACKEND_API + "/product-info-identity")
@RequiredArgsConstructor
@Slf4j
public class ProductInfoIdentityController {
    private final ProductInfoIdentityService productInfoIdentityService;

    @Operation(summary = "分页列表")
    @GetMapping("/page")
    @Log(value = "分页列表", module = LogModuleEnum.PRODUCT_INFO_IDENTITY)
    // @DataPermission(permissionCode = "warehouse:arrival-order:data-permission")
    public Result<PageResultBean<ProductInfoIdentityVO>> listPaged(ProductInfoIdentityPageQuery queryParams) {
        PageResultBean<ProductInfoIdentityVO> result = productInfoIdentityService.listPage(queryParams);
        return Result.success(result);
    }

    @Operation(summary = "分页聚合列表")
    @GetMapping("/page/group")
    @Log(value = "分页聚合列表", module = LogModuleEnum.PRODUCT_INFO_IDENTITY_GROUP)
    // @DataPermission(permissionCode = "warehouse:arrival-order:data-permission")
    public Result<List<ProductInfoIdentityGroupVO>> listPagedGroup(ProductInfoIdentityPageGroupQuery queryParams) {
        List<ProductInfoIdentityGroupVO> result = productInfoIdentityService.listPageGroup(queryParams);
        return Result.success(result);
    }

    @Operation(summary = "扫码获取详情")
    @GetMapping("/getDetail")
    @Log(value = "扫码获取详情", module = LogModuleEnum.PRODUCT_INFO_IDENTITY_GROUP)
    // @DataPermission(permissionCode = "warehouse:arrival-order:data-permission")
    public Result<ProductInfoDetailVO> getPackIngOrIdentityCode(@RequestParam("packingOrIdentityCode") String packingOrIdentityCode) {
        ProductInfoDetailVO productInfoDetailVO = productInfoIdentityService.getPackIngOrIdentityCode(packingOrIdentityCode);
        return Result.success(productInfoDetailVO);
    }
}
